<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 6，统计字符串中每个字符的个数，并去掉连续重复的字符。（原始：“aabccdeefff”,统计后是：a2 b1 c2 d1 e2 f3，取重后是：abcdef）  -->
    <script>
        var str = "aabccdeefff";
        str = str.split("");
        var a = '';
        for (var i = 0; i < str.length; i++) {
            count = 1;
            for (var j = i + 1; j < str.length; j++) {
                if (str[i] == str[j]) {
                    count++;
                    str.splice(j--, 1)
                }
            }
            a += str[i]

            str[i] += count;
        }
        console.log(str.join(""));
        console.log(a);
    </script>

</body>

</html>